package a.a;

import a.c.a;
import a.c.bb;
import a.c.d;
import a.c.e;
import a.c.k;
import a.c.n;
import a.c.q;
import a.c.w;
import a.i.mb;

class j
{
  private static final int a = 2147483647;
  private e[] b;
  private d[] c;
  private int[] d;
  private int[] e;
  private int[] f;
  private int[] g;
  private int[] h;
  private int i;
  private int j;
  private e k;
  private e l;
  private q m;
  private int n;
  private int o;
  private int p;
  private s q;
  private boolean r = true;
  private bb s;
  private bb u;
  private a_ v = new a_();
  private boolean w;
  private int x;
  private int y = 5;
  private int z;
  
  public String a()
  {
    return this.v.toString();
  }
  
  public int b()
  {
    return this.y;
  }
  
  public void a(int paramInt)
  {
    this.y = paramInt;
  }
  
  void a(s params)
  {
    this.r = false;
    this.q = params;
  }
  
  public int a(q paramq, e parame1, e parame2, k paramk, n paramn)
  {
    int i11 = m.b;
    boolean bool = m.a;
    this.v.a();
    if (i11 == 0) {
      if (parame2 == parame1) {
        throw new a("source == sink");
      }
    }
    if (i11 == 0) {
      if (parame1.e() != 0)
      {
        if (i11 == 0) {
          if (parame2.d() != 0) {
            break label70;
          }
        }
      }
      else {
        this.v.c();
      }
    }
    return 0;
    label70:
    a(paramq, parame1, parame2, paramk);
    break label275;
    break label275;
    break label250;
    break label275;
    break label1013;
    label79:
    label90:
    label100:
    label250:
    label1532:
    do
    {
      do
      {
        do
        {
          do
          {
            e locale1;
            int i1;
            int i8;
            do
            {
              Object localObject;
              d locald;
              int i4;
              e locale2;
              int i5;
              do
              {
                locale1 = this.q.a();
                if (locale1 == null)
                {
                  if (this.n == 2) {
                    break label1708;
                  }
                  i2 = 0;
                  if (i2 < this.i) {}
                  while (i11 != 0)
                  {
                    this.d[i2] = this.i;
                    i2++;
                    if (i11 != 0) {
                      break label157;
                    }
                    if (bool) {
                      break label156;
                    }
                    if (!bool) {
                      break;
                    }
                  }
                  c();
                  i2 = 0;
                  if (i2 >= this.i) {}
                }
                int i3;
                do
                {
                  if (bool) {
                    break label100;
                  }
                  if (this.d[i2] == this.i)
                  {
                    this.s.add(this.b[i2]);
                    this.d[i2] = this.o;
                  }
                  i2++;
                  if (!bool) {
                    break label159;
                  }
                  this.n = 2;
                  d();
                  if (i11 != 0) {
                    break label90;
                  }
                  if (i11 != 0) {
                    break label161;
                  }
                  if (!bool) {
                    break;
                  }
                  i1 = locale1.f();
                  if (locale1 == this.l) {
                    break;
                  }
                  if (this.d[i1] == this.i) {
                    if ((i11 == 0) && (this.n == 1)) {
                      break;
                    }
                  }
                  i2 = this.e[i1];
                  i3 = this.d[i1];
                  i8 = 2147483647;
                  int i6;
                  if (this.d[i1] < this.i)
                  {
                    localObject = locale1.n();
                    do
                    {
                      if (!((a.c.m)localObject).e()) {
                        break;
                      }
                      this.v.g += 1;
                      locald = ((a.c.m)localObject).a();
                      i4 = locald.d();
                      int i7 = this.g[i4] - this.f[i4];
                      if (bool) {
                        break label604;
                      }
                      if (i7 != 0)
                      {
                        locale2 = locald.f();
                        i5 = locale2.f();
                        i6 = this.d[i5];
                        if (i11 == 0)
                        {
                          if (i6 < i3)
                          {
                            this.v.e += 1;
                            if (i11 == 0) {
                              if (this.e[i5] == 0) {
                                this.q.c(locale2, i6);
                              }
                            }
                            if (i11 == 0)
                            {
                              if (i2 <= i7)
                              {
                                this.e[i5] += i2;
                                this.f[i4] += i2;
                                i2 = 0;
                                if (i11 == 0) {
                                  if (!bool) {
                                    break;
                                  }
                                }
                              }
                              else
                              {
                                this.e[i5] += i7;
                                this.f[i4] += i7;
                              }
                            }
                            else {
                              i2 -= i7;
                            }
                            if (i11 != 0) {
                              continue;
                            }
                            if (!bool) {}
                          }
                          else
                          {
                            if (i11 != 0) {
                              continue;
                            }
                          }
                        }
                        else if (i6 < i8) {
                          i8 = i6;
                        }
                      }
                      ((a.c.m)localObject).f();
                    } while (!bool);
                  }
                  if (i11 == 0)
                  {
                    if (i2 > 0)
                    {
                      localObject = locale1.m();
                      do
                      {
                        if (!((a.c.m)localObject).e()) {
                          break;
                        }
                        this.v.g += 1;
                        locald = ((a.c.m)localObject).a();
                        i4 = locald.d();
                        if (bool) {
                          break label889;
                        }
                        if (this.f[i4] != 0)
                        {
                          locale2 = locald.e();
                          i5 = locale2.f();
                          i6 = this.d[i5];
                          if (i11 == 0)
                          {
                            if (i6 < i3)
                            {
                              this.v.e += 1;
                              if (i11 == 0) {
                                if (this.e[i5] == 0) {
                                  this.q.c(locale2, i6);
                                }
                              }
                              if (i11 == 0)
                              {
                                if (i2 <= this.f[i4])
                                {
                                  this.f[i4] -= i2;
                                  this.e[i5] += i2;
                                  i2 = 0;
                                  if (i11 != 0) {
                                    break label887;
                                  }
                                  if (!bool) {
                                    break;
                                  }
                                }
                                this.e[i5] += this.f[i4];
                              }
                              i2 -= this.f[i4];
                              this.f[i4] = 0;
                              if (i11 != 0) {
                                continue;
                              }
                              if (!bool) {}
                            }
                            else
                            {
                              if (i11 != 0) {
                                continue;
                              }
                            }
                          }
                          else if (i6 < i8) {
                            i8 = i6;
                          }
                        }
                        ((a.c.m)localObject).f();
                      } while (!bool);
                    }
                    this.e[i1] = i2;
                  }
                  if (i11 != 0) {
                    break label90;
                  }
                  if (i2 <= 0) {
                    break;
                  }
                } while (i11 != 0);
                if (bool) {
                  break;
                }
                if (this.v.g > this.z) {
                  break label1425;
                }
                this.v.d += 1;
                if (i11 != 0) {
                  break label1417;
                }
                if (this.n != 1) {
                  break label1390;
                }
                if (i11 == 0)
                {
                  if (this.h[i3] -= 1 != 0)
                  {
                    if (i11 != 0) {
                      break label1382;
                    }
                    if (i8 < this.i - 1) {
                      break label1339;
                    }
                  }
                  this.d[i1] = this.i;
                }
              } while ((i11 == 0) && (i8 >= this.i));
              this.u.add(locale1);
              do
              {
                a.c.m localm;
                int i10;
                do
                {
                  if (this.u.isEmpty()) {
                    break label79;
                  }
                  locale2 = this.u.o();
                  i5 = locale2.f();
                  this.v.i += 1;
                  localm = locale2.n();
                  do
                  {
                    do
                    {
                      if (!localm.e()) {
                        break label1189;
                      }
                      locald = localm.a();
                      i4 = locald.d();
                      localObject = locald.f();
                      i10 = ((e)localObject).f();
                      if (bool) {
                        break;
                      }
                      if (this.f[i4] < this.g[i4])
                      {
                        if (i11 != 0) {
                          continue;
                        }
                        if (this.d[i10] < this.i)
                        {
                          this.u.add(localObject);
                          this.h[this.d[i10]] -= 1;
                          this.d[i10] = this.i;
                        }
                      }
                      localm.f();
                    } while (!bool);
                  } while (i11 != 0);
                  localm = locale2.m();
                  if (!localm.e()) {
                    break;
                  }
                  locald = localm.a();
                  i4 = locald.d();
                  localObject = locald.e();
                  i10 = ((e)localObject).f();
                  if (i11 != 0) {
                    break;
                  }
                  if (bool) {
                    break;
                  }
                  if (i11 != 0) {
                    break;
                  }
                } while (bool);
                if (this.f[i4] > 0)
                {
                  if (i11 != 0) {
                    break label1336;
                  }
                  if (this.d[i10] < this.i)
                  {
                    this.u.add(localObject);
                    this.h[this.d[i10]] -= 1;
                    this.d[i10] = this.i;
                  }
                }
                localm.f();
                if (!bool) {
                  break label1012;
                }
                this.d[i1] = (++i8);
                this.h[i8] += 1;
                this.q.a(locale1, i8);
              } while (i11 != 0);
              if (i11 != 0) {
                break label1417;
              }
            } while (!bool);
            this.d[i1] = (++i8);
            this.q.a(locale1, i8);
            if (i11 != 0) {
              break label1469;
            }
          } while (!bool);
          this.z += this.x;
          this.v.h += 1;
          this.q.c();
          if (i11 != 0) {
            break label1630;
          }
          if (this.n != 1) {
            break label1629;
          }
          i9 = 0;
          if (i9 < this.i) {}
          while (i11 != 0)
          {
            this.d[i9] = this.i;
            i9++;
            if (i11 != 0) {
              break label1532;
            }
            if (bool) {
              break label1523;
            }
            if (!bool) {
              break;
            }
          }
          c();
        } while ((i11 == 0) && (!this.q.b()));
        int i9 = 0;
        do
        {
          do
          {
            if (i9 >= this.i) {
              break label1605;
            }
            if (bool) {
              break;
            }
            if (this.d[i9] == this.i)
            {
              this.s.add(this.b[i9]);
              this.d[i9] = this.o;
            }
            i9++;
          } while (!bool);
          this.n = 2;
          if (i11 != 0) {
            break label1630;
          }
          d();
        } while (i11 != 0);
      } while (!bool);
      w localw = this.s.l();
      if (localw.e()) {}
      while (i11 != 0)
      {
        this.d[localw.d().f()] = this.o;
        localw.f();
        if (i11 != 0) {
          break label1700;
        }
        if (bool) {
          break label1698;
        }
        if (!bool) {
          break;
        }
      }
      d();
    } while ((i11 == 0) && (!bool));
    label156:
    label157:
    label159:
    label161:
    label604:
    label887:
    label889:
    if (i11 == 0) {
      if (!e()) {
        System.err.println("checkMaxFlow failed !");
      }
    }
    label275:
    label1012:
    label1013:
    int i2 = 0;
    label1189:
    label1336:
    label1339:
    label1382:
    label1390:
    label1523:
    if (i2 < this.j) {}
    label1417:
    label1425:
    label1469:
    label1605:
    label1629:
    label1630:
    do
    {
      if (bool) {
        break label1851;
      }
      if (this.w) {
        if (i11 == 0)
        {
          if (this.f[i2] == this.p) {
            paramn.a(this.c[i2], 2147483647);
          }
        }
        else
        {
          if (i11 != 0) {
            break label1823;
          }
          if (!bool) {
            break label1818;
          }
        }
      }
      paramn.a(this.c[i2], this.f[i2]);
      i2++;
      if (!bool) {
        break;
      }
      this.v.c();
      i2 = this.l.f();
    } while (i11 != 0);
    label1698:
    label1700:
    label1708:
    if (this.w)
    {
      label1851:
      if (i11 != 0) {
        break label1883;
      }
      if (this.e[i2] >= this.p) {
        return 2147483647;
      }
    }
    label1818:
    label1823:
    label1883:
    return this.e[i2];
  }
  
  private void a(q paramq, e parame1, e parame2, k paramk)
  {
    int i5 = m.b;
    boolean bool = m.a;
    this.m = paramq;
    this.k = parame1;
    this.l = parame2;
    this.i = this.m.k();
    this.j = this.m.m();
    this.o = (2 * this.i - 1);
    this.n = 1;
    this.b = this.m.t();
    this.c = new d[this.j];
    this.d = new int[this.i];
    this.e = new int[this.i];
    this.f = new int[this.j];
    this.g = new int[this.j];
    if (i5 == 0)
    {
      if (this.r) {
        this.q = new eb(this.o);
      }
      this.u = new bb();
      this.s = new bb();
      this.x = (this.y * this.j);
      this.z = this.x;
      this.p = 0;
      this.w = false;
    }
    a.c.m localm1 = this.m.w();
    d locald;
    int i1;
    do
    {
      if (!localm1.e()) {
        break;
      }
      locald = localm1.a();
      i1 = locald.d();
      int i2 = paramk.getInt(locald);
      if (bool) {
        break label358;
      }
      if (i2 < 0) {
        throw new a("found negative capacity");
      }
      if (i5 == 0)
      {
        if (i2 == 2147483647)
        {
          this.w = true;
          if (i5 != 0) {
            continue;
          }
          if (!bool) {}
        }
        else
        {
          if (i5 != 0) {
            continue;
          }
        }
      }
      else if (i2 > this.p) {
        this.p = i2;
      }
      this.c[i1] = locald;
      this.g[i1] = i2;
      localm1.f();
    } while (!bool);
    label358:
    int i3;
    if (i5 == 0)
    {
      if (this.w)
      {
        this.p = (this.p * this.j + 1);
        if (i5 == 0) {
          if (this.p < 0) {
            throw new RuntimeException("MaxFlow Error:  Integer-Overflow by infinity scaling!");
          }
        }
        i3 = 0;
        do
        {
          if (i3 >= this.j) {
            break;
          }
          if (bool) {
            break label465;
          }
          if (this.g[i3] == 2147483647) {
            this.g[i3] = this.p;
          }
          i3++;
        } while (!bool);
      }
      if ((i5 != 0) || (2147483647 / this.k.e() < this.p)) {
        label465:
        System.err.println("Warning: Integer-Overflow possible!");
      }
    }
    a.c.m localm2 = this.k.n();
    do
    {
      if (!localm2.e()) {
        break;
      }
      locald = localm2.a();
      i1 = locald.d();
      i3 = this.g[i1];
      if (bool) {
        break label587;
      }
      if (i3 != 0)
      {
        this.f[i1] = i3;
        this.e[locald.f().f()] += i3;
        this.e[this.k.f()] -= i3;
      }
      localm2.f();
    } while (!bool);
    label587:
    int i4 = 0;
    if (i4 < this.i) {}
    while (i5 != 0)
    {
      this.d[i4] = this.i;
      i4++;
      if ((i5 == 0) && (bool)) {
        return;
      }
      if (!bool) {
        break;
      }
    }
    c();
  }
  
  private void c()
  {
    int i5 = m.b;
    boolean bool = m.a;
    this.u.add(this.l);
    this.d[this.l.f()] = 0;
    this.h = new int[this.i];
    this.h[0] = 1;
    label250:
    do
    {
      if (!this.u.isEmpty())
      {
        e locale1 = this.u.o();
        int i1 = locale1.f();
        int i4;
        a.c.m localm;
        d locald;
        int i2;
        e locale2;
        int i3;
        do
        {
          i4 = this.d[i1] + 1;
          localm = locale1.n();
          do
          {
            do
            {
              if (!localm.e()) {
                break;
              }
              locald = localm.a();
              i2 = locald.d();
              if (bool) {
                break label250;
              }
              if (this.f[i2] != 0)
              {
                locale2 = locald.f();
                i3 = locale2.f();
                if (i5 != 0) {
                  continue;
                }
                if (this.d[i3] >= this.i)
                {
                  this.d[i3] = i4;
                  this.u.add(locale2);
                  this.h[i4] += 1;
                  if (i5 != 0) {
                    continue;
                  }
                  if (this.e[i3] > 0) {
                    this.q.a(locale2, i4);
                  }
                }
              }
              localm.f();
            } while (!bool);
          } while (i5 != 0);
          localm = locale1.m();
          if (!localm.e()) {
            break;
          }
          locald = localm.a();
          i2 = locald.d();
        } while (bool);
        if (this.g[i2] != this.f[i2])
        {
          locale2 = locald.e();
          i3 = locale2.f();
          if (i5 != 0) {
            break label388;
          }
          if (this.d[i3] >= this.i)
          {
            this.d[i3] = i4;
            this.u.add(locale2);
            this.h[i4] += 1;
            if (i5 != 0) {
              break label388;
            }
            if (this.e[i3] > 0) {
              this.q.a(locale2, i4);
            }
          }
        }
        localm.f();
        if (!bool) {
          break;
        }
      }
    } while (i5 != 0);
    label388:
  }
  
  private void d()
  {
    int i5 = m.b;
    boolean bool = m.a;
    this.u.add(this.k);
    do
    {
      this.d[this.k.f()] = this.i;
      int i4;
      a.c.m localm;
      d locald;
      do
      {
        if (this.u.isEmpty()) {
          break;
        }
        e locale1 = this.u.o();
        int i1 = locale1.f();
        int i2;
        do
        {
          i4 = this.d[i1] + 1;
          localm = locale1.n();
          if (!localm.e()) {
            break;
          }
          locald = localm.a();
          i2 = locald.d();
        } while (i5 != 0);
      } while (bool);
      if (this.f[i2] != 0)
      {
        e locale2 = locald.f();
        int i3 = locale2.f();
        if (i5 != 0) {
          continue;
        }
        if (this.d[i3] == this.o)
        {
          this.d[i3] = i4;
          if (i5 == 0) {
            if (this.e[i3] > 0) {
              this.q.a(locale2, i4);
            }
          }
          this.u.add(locale2);
        }
      }
      localm.f();
    } while (!bool);
  }
  
  private boolean e()
  {
    int i5 = m.b;
    boolean bool = m.a;
    int[] arrayOfInt = new int[this.i];
    int i3 = 0;
    label90:
    int i1;
    int i2;
    do
    {
      if (i3 >= this.j) {
        break;
      }
      if (bool) {
        break label149;
      }
      if (this.f[i3] >= 0)
      {
        if (i5 != 0) {
          break label90;
        }
        if (this.f[i3] <= this.g[i3]) {}
      }
      else
      {
        System.err.println("checkMaxFlow: found wrong flow value!");
        return false;
      }
      i1 = this.c[i3].e().f();
      i2 = this.c[i3].f().f();
      arrayOfInt[i1] -= this.f[i3];
      arrayOfInt[i2] += this.f[i3];
      i3++;
    } while (!bool);
    if (i5 == 0) {
      label149:
      i3 = 0;
    }
    do
    {
      while (!bool)
      {
        if (i3 >= this.i) {
          break;
        }
        if (bool) {
          break label235;
        }
        if ((i5 != 0) || ((this.b[i3] != this.k) && (this.b[i3] != this.l)))
        {
          if (i5 != 0) {
            continue;
          }
          if (arrayOfInt[i3] != 0)
          {
            System.err.println("checkMaxFlow: found wrong excess!");
            return false;
          }
        }
        i3++;
      }
    } while (i5 != 0);
    label235:
    boolean[] arrayOfBoolean = new boolean[this.i];
    bb localbb = new bb();
    localbb.add(this.k);
    arrayOfBoolean[this.k.f()] = true;
    label297:
    label299:
    label509:
    do
    {
      for (;;)
      {
        if (!localbb.isEmpty())
        {
          e locale1 = localbb.o();
          i1 = locale1.f();
          a.c.m localm = locale1.n();
          d locald;
          int i4;
          e locale2;
          if (localm.e())
          {
            locald = localm.a();
            i4 = locald.d();
            locale2 = locald.f();
            i2 = locale2.f();
          }
          do
          {
            if ((i5 != 0) || (!bool))
            {
              if (this.f[i4] < this.g[i4])
              {
                if (i5 != 0) {
                  break label397;
                }
                if (arrayOfBoolean[i2] == 0)
                {
                  arrayOfBoolean[i2] = true;
                  localbb.add(locale2);
                }
              }
              localm.f();
              if (!bool) {
                break label297;
              }
              if (i5 != 0) {
                break label299;
              }
              localm = locale1.m();
            }
            if (!localm.e()) {
              break;
            }
            locald = localm.a();
            i4 = locald.d();
            locale2 = locald.e();
            i2 = locale2.f();
          } while (i5 != 0);
          if (!bool)
          {
            if (bool) {
              break label527;
            }
            if (this.f[i4] > 0)
            {
              if (i5 != 0) {
                break label509;
              }
              if (arrayOfBoolean[i2] == 0)
              {
                arrayOfBoolean[i2] = true;
                localbb.add(locale2);
              }
            }
            localm.f();
            if (!bool) {
              break;
            }
          }
        }
      }
    } while (i5 != 0);
    label397:
    if (arrayOfBoolean[this.l.f()] != 0)
    {
      label527:
      System.err.println("checkMaxFlow: t reachable from s!");
      return false;
    }
    return true;
  }
  
  static class a_
  {
    private String a;
    private mb b = new mb();
    int d;
    int e;
    int g;
    int h;
    int i;
    
    public void a()
    {
      this.d = 0;
      this.e = 0;
      this.g = 0;
      this.h = 0;
      this.i = 0;
      this.a = "0";
      this.b.a();
      this.b.g();
    }
    
    public void c()
    {
      this.a = this.b.toString();
    }
    
    public String toString()
    {
      return "\nMaxFlow-Statistics:\n   Time: " + this.a + "\n   Pushes: " + this.e + "\n   Inspections: " + this.g + "\n   Relabels: " + this.d + "\n   GlobalRelabels: " + this.h + "\n   Gaps: " + this.i;
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.a.j

 * JD-Core Version:    0.7.0.1

 */